#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
struct ListNode{
    int val;
    struct ListNode* next;
};
struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2) {
    struct ListNode* newhead = NULL, * up = NULL, * dow = NULL, * tmp = NULL;
    up = list1;
    dow = list2;
    tmp = newhead;
    while (up && dow)
    {
        if (up->val <= dow->val)
        {
            if (newhead)
            {
                tmp = up;
                up = up->next;
                tmp = tmp->next;
            }
            else
            {
                newhead = up;
                tmp = newhead->next;
                up = up->next;
            }
        }
        else {
            if (newhead)
            {
                tmp = dow;
                dow = dow->next;
                tmp = tmp->next;
            }
            else
            {
                newhead = dow;
                tmp = newhead->next;
                dow = dow->next;
            }
        }
    }
    if (dow)
    {
        tmp = dow;
    }
    if (up)
    {
        tmp = up;
    }
    return newhead;
}

int main()
{
    
}